//
//  LaunchViewController.m
//  WXMovie
//
//  Created by HZApple on 16/4/8.
//  Copyright © 2016年 无限互联. All rights reserved.
//

#import "LaunchViewController.h"
#import "RootTabBarController.h"

@interface LaunchViewController ()<UIScrollViewDelegate>

@end

@implementation LaunchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
    scrollView.pagingEnabled = YES;
    scrollView.delegate = self;
    scrollView.contentSize = CGSizeMake(5 * kScreenWidth, 0);
    scrollView.showsHorizontalScrollIndicator = NO;
   
    for (int i = 0; i < 5; i++) {
        NSString *imageName = [NSString stringWithFormat:@"guide%d@2x", i + 1];
        NSString *progressImageName = [NSString stringWithFormat:@"guideProgress%d@2x", i + 1];
        
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(i * kScreenWidth, 0, kScreenWidth, kScreenHeight)];
        imageView.image = [UIImage imageNamed:imageName];
        
        UIImageView *progressView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:progressImageName]];
        progressView.frame = CGRectMake((kScreenWidth - progressView.image.size.width) / 2, kScreenHeight - 50, progressView.image.size.width, progressView.image.size.height);
        
        [imageView addSubview:progressView];
        [scrollView addSubview:imageView];
    }
    [self.view addSubview:scrollView];
    
    // Do any additional setup after loading the view.
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
     CGFloat x = scrollView.contentOffset.x;
    //NSLog(@"%f",x);
    if (x == 4 * kScreenWidth) {
        self.view.window.rootViewController = [[RootTabBarController alloc] init] ;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
